define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/walletlog/index',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                queryParams:function(params){
                    var filter=JSON.parse(params.filter);
                    var op = JSON.parse(params.op);
                    var id=Fast.api.query('user_id');
                    if (id){
                        filter.user_id=id;
                        op.user_id='=';
                        params.filter=JSON.stringify(filter);
                        params.op = JSON.stringify(op);
                        //funcUrlDel('library_id');
                    }
                    return params;
                },    
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'wallet', title: __('佣金'), operate: 'LIKE'},
                        {field: 'memo', title: __('类型'), operate: 'LIKE'},
                        {field: 'createtime', title: __('时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'temp_source', title: __('来源'), operate: false},
                        {field: 'temp_order_no', title: __('订单编号'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});